<template>
  <div class="issues-detail">
    <div class="issues-detail__item pass-item">
      <span class="label">结果：</span>
      <span class="pass-box" :class="[detail ? (detail.pass ? 'passed' : 'no-passed') : '']">{{
        detail ? (detail.pass ? '符合' : '不符合') : ''
      }}</span>
    </div>
    <div class="issues-detail__item">
      <span class="label">说明：</span>
      <span>{{ detail?.content }}</span>
    </div>
    <div class="issues-detail__item item-bottom">
      <div>
        <span>优先级：</span>
        <span>
          <span
            class="priority-circle"
            :style="{ background: PRIORITY_CODES[detail?.priority]?.color }"
          ></span>
          <span>{{ detail?.priorityValue }}</span>
        </span>
      </div>
      <div style="width: 148px">
        <span>截止日期：</span>
        <span>{{ detail?.endTime }}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defineProps, PropType } from 'vue'

import { PRIORITY_CODES } from '@/configs/codeMaps'
import IBaseObj from '#/index'

defineProps({
  detail: {
    type: Object as PropType<IBaseObj>,
    default: () => {},
  },
  isQc: {
    type: Boolean,
    default: false,
  },
})
</script>

<style lang="scss" scoped>
.issues-detail {
  &__item {
    display: flex;
    margin-bottom: 15px;

    &:last-child {
      margin-bottom: 0;
    }

    .label {
      flex-shrink: 0;
    }
  }
}

.pass-item {
  height: 24px;
  align-items: center;
}

.pass-box {
  padding: 2px 8px;
  border-radius: 4px;

  &.passed {
    color: #94c106;
    border: 1px solid #94c106;
  }

  &.no-passed {
    color: #ff4838;
    border: 1px solid #ff4838;
  }
}

.item-bottom {
  justify-content: space-between;
}

.priority-circle {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  vertical-align: middle;
  border-radius: 50%;
}
</style>
